package com.ruoyi.web.controller.base;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.base.domain.SysApiapplyData;
import com.ruoyi.base.service.ISysApiapplyDataService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 接口访问申请Controller
 * 
 * @author ruoyi
 * @date 2025-08-03
 */
@RestController
@RequestMapping("/system/apiapplydata")
public class SysApiapplyDataController extends BaseController
{
    @Autowired
    private ISysApiapplyDataService sysApiapplyDataService;

    /**
     * 查询接口访问申请列表
     */
    //@PreAuthorize("@ss.hasPermi('system:DATA:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysApiapplyData sysApiapplyData)
    {
        startPage();
        List<SysApiapplyData> list = sysApiapplyDataService.selectSysApiapplyDataList(sysApiapplyData);
        return getDataTable(list);
    }


    /**
     * 导出接口访问申请列表
     */
    //@PreAuthorize("@ss.hasPermi('system:DATA:export')")
    //@Log(title = "接口访问申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysApiapplyData sysApiapplyData)
    {
        List<SysApiapplyData> list = sysApiapplyDataService.selectSysApiapplyDataList(sysApiapplyData);
        ExcelUtil<SysApiapplyData> util = new ExcelUtil<SysApiapplyData>(SysApiapplyData.class);
        util.exportExcel(response, list, "接口访问申请数据");
    }

    /**
     * 获取接口访问申请详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:DATA:query')")
    @GetMapping(value = "/getinfo/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(sysApiapplyDataService.selectSysApiapplyDataById(id));
    }

    /**
     * 新增接口访问申请
     */
    //@PreAuthorize("@ss.hasPermi('system:DATA:add')")
    //@Log(title = "接口访问申请", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody SysApiapplyData sysApiapplyData)
    {
        return toAjax(sysApiapplyDataService.insertSysApiapplyData(sysApiapplyData));
    }

    /**
     * 修改接口访问申请
     */
    //@PreAuthorize("@ss.hasPermi('system:DATA:edit')")
    //@Log(title = "接口访问申请", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody SysApiapplyData sysApiapplyData)
    {
        sysApiapplyData.setApproveuser(getUsername());
        return toAjax(sysApiapplyDataService.updateSysApiapplyData(sysApiapplyData));
    }

    /**
     * 删除接口访问申请
     */
    //@PreAuthorize("@ss.hasPermi('system:DATA:remove')")
    //@Log(title = "接口访问申请", businessType = BusinessType.DELETE)
	@GetMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(sysApiapplyDataService.deleteSysApiapplyDataByIds(ids));
    }
}
